import { PURCHASEWAY_OPTIONS } from '@/constant/purchase'
import { Empty } from 'antd'
import dayjs from 'dayjs'
export const searchConfig = ({
  DICTDATA,
  SupplierOption,
  handleSearchSupplier,
  UserOptions,
  handleSearchUser,
}: {
  DICTDATA: IDICTDATAType
  SupplierOption: IOptionItem[]
  handleSearchSupplier: (newValue?: string) => void
  UserOptions: IOptionItem[]
  handleSearchUser: (newValue?: string) => void
}): IItemArray[] => {
  return [
    {
      name: 'year',
      label: '年份',
      type: 'FixedDatePicker',
      placeholder: '请选择年份',
      rules: [
        {
          required: true,
          message: '请选择年份',
        },
      ],
      config: {
        picker: 'year',
        format: 'YYYY',
        minDate: dayjs('2025'),
        customFormat: 'YYYY',
      },
    },
    {
      label: '商品范围',
      name: 'productScope',
      type: 'Select',
      option: [
        { label: '全部', value: 0 },
        { label: '本周主力商品', value: 1 },
      ],
      config: {
        showSearch: true,
        optionFilterProp: 'label',
      },
    },
    {
      label: '订单范围',
      name: 'orderScope',
      type: 'Select',
      option: [
        { label: '全部', value: 0 },
        { label: '剔除未到货', value: 1 },
      ],
      config: {
        showSearch: true,
        optionFilterProp: 'label',
      },
    },
    {
      label: '跟单分组',
      name: 'trackPersonGroup',
      type: 'Select',
      option: [
        { label: '全部', value: 0 },
        { label: '跟单组', value: 1 },
        { label: '现采组', value: 2 },
      ],
      config: {
        showSearch: true,
        optionFilterProp: 'label',
      },
    },
    {
      name: 'supplierId',
      label: '供应商',
      type: 'Select',
      option: SupplierOption,
      placeholder: '请选择供应商',
      config: {
        showSearch: true,
        optionFilterProp: 'label',
        filterOption: false,
        onSearch: handleSearchSupplier,
      },
    },
    {
      label: '供应链跟单',
      name: 'trackOrderPerson',
      type: 'Select',
      option: UserOptions,
      config: {
        showSearch: true,
        optionFilterProp: 'label',
        filterOption: false,
        onSearch: handleSearchUser,
        notFoundContent: <Empty description="请输入内容搜索" image={Empty.PRESENTED_IMAGE_SIMPLE} />,
        fieldNames: { label: 'label', value: 'name' },
      },
    },
    {
      name: 'seasonCodes',
      label: '季节分组',
      type: 'Select',
      option: DICTDATA.season_classify,
      placeholder: '请选择季节分组',
      config: {
        suffixIcon: null,
        showSearch: true,
        optionFilterProp: 'label',
        filterOption: true,
        mode: 'multiple',
        maxTagCount: 'responsive',
      },
    },
    {
      label: '采购方式',
      name: 'purchaseType',
      type: 'Select',
      option: PURCHASEWAY_OPTIONS,
      config: {
        showSearch: true,
        optionFilterProp: 'label',
      },
    },
  ]
}

export const useFormExport = (): IItemArray[] => {
  return [
    {
      label: '导出数据维度',
      name: 'exportDataTypeList',
      type: 'Checkbox',
      option: [
        { label: '色', value: 'exportSkc' },
        { label: '尺码', value: 'exportSku' },
      ],
    },
  ]
}
